import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'
import type { DataExportAO } from '/@/model/cn/core/tool/ao/DataExportAO'

import taskExpressionService from '/@/api/cn/core/kpis/taskExpressionService'

import type { TaskExpression } from '/@/model/cn/core/kpis/eo/TaskExpression'
import type { TaskExpressionQO } from '/@/model/cn/core/kpis/qo/TaskExpressionQO'
import type { TaskExpressionVO } from '/@/model/cn/core/kpis/vo/TaskExpressionVO'

interface TaskExpressionState {
}

export const useTaskExpressionStore = defineStore({
  id: 'taskExpression',
  state: (): TaskExpressionState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<TaskExpression>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.save(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<TaskExpression>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.saveBatch(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<TaskExpression>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.update(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<TaskExpression>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.updateBatch(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<TaskExpression>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.remove(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<TaskExpression>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.removeBatch(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<TaskExpressionQO>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.count(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<TaskExpressionQO>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.pk(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<TaskExpressionQO>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.query(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<TaskExpressionQO>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.paging(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<TaskExpressionQO>): Promise<Res<TaskExpressionVO>> {
      return new Promise<Res<TaskExpressionVO>>((resolve, reject) => {
        taskExpressionService.countVo(param).then((res: AxiosResponse<Res<TaskExpressionVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<TaskExpressionQO>): Promise<Res<TaskExpressionVO>> {
      return new Promise<Res<TaskExpressionVO>>((resolve, reject) => {
        taskExpressionService.pkVo(param).then((res: AxiosResponse<Res<TaskExpressionVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<TaskExpressionQO>): Promise<Res<TaskExpressionVO>> {
      return new Promise<Res<TaskExpressionVO>>((resolve, reject) => {
        taskExpressionService.queryVo(param).then((res: AxiosResponse<Res<TaskExpressionVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<TaskExpressionQO>): Promise<Res<TaskExpressionVO>> {
      return new Promise<Res<TaskExpressionVO>>((resolve, reject) => {
        taskExpressionService.pagingVo(param).then((res: AxiosResponse<Res<TaskExpressionVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataImport(param: Param<string>): Promise<Res<TaskExpression>> {
      return new Promise<Res<TaskExpression>>((resolve, reject) => {
        taskExpressionService.dataImport(param).then((res: AxiosResponse<Res<TaskExpression>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataExport(param: Param<DataExportAO<TaskExpressionQO>>): Promise<Res<string>> {
      return new Promise<Res<string>>((resolve, reject) => {
        taskExpressionService.dataExport(param).then((res: AxiosResponse<Res<string>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useTaskExpressionStoreWithout() {
  return useTaskExpressionStore(store)
}
